import React, { Component } from 'react';

// 组件更新 传一个新的属性进去
class Demo extends Component{
  state = {

  }
  static getDerivedStateFromProps(props,state){
    console.log(props);
    return props;
  }
  shouldComponentUpdate(){
    return false;// 减少不必要的更新 提升渲染性能
    // console.log("Demo 组件更新了");
    // return true;
  }
  render(){
    return <div>
      <h1>Demo 组件</h1>
    </div>
  }
}
class App extends Component {
  state = {
    msg:"(*^_^*)"
  }
  render() {
    return (
      <div>
        <button onClick={()=>{
          this.setState({
            msg:"😀"
          })
        }}>更新msg</button>
        {/* <Demo msg={this.state.msg}></Demo> */}
        <Demo></Demo>
      </div>
    );
  }
}

export default App;
